package com.duoec.doc.doclet.annotation.param;

import com.duoec.doc.doclet.annotation.ParamAnnotation;
import com.duoec.doc.doclet.helper.AnnotationHelper;
import com.duoec.doc.doclet.pojo.EntityRef;
import com.sun.javadoc.AnnotationDesc;

import java.io.Serializable;
import java.util.Map;

/**
 * @author xuwenzhen
 */
public abstract class BaseSpringMvcParamAnnotation implements ParamAnnotation {
    protected void paramNameReset(EntityRef param, AnnotationDesc annotationDesc) {
        if (annotationDesc == null) {
            return;
        }
        Map<String, Serializable> annotationMap = AnnotationHelper.getAnnotations(annotationDesc);
        param.setAnnotationParams(annotationMap);
        String value = AnnotationHelper.getStringValue(annotationDesc, "value");
        if (value != null && value.length() > 0) {
            param.setName(value);
            return;
        }
        value = AnnotationHelper.getStringValue(annotationDesc, "name");
        if (value != null && value.length() > 0) {
            param.setName(value);
        }
    }
}
